﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddModel.aspx.cs" Inherits="CURE.SystemManagement.AddModel" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        $(document).ready(function () {
            var fatherName = "<%=FatherName %>";
            if (fatherName != null && fatherName != "") {
                $("#father").attr("value", fatherName);
            }
        });
        function ckChinese() {
            var reg = /[^\x00-\xff]/g;
            var url = document.getElementById("txturl").value;
            if (reg.test(url) == true) {
                alert("url含有汉字及中文输入法下符号");
                return false;
            }
        }
        function checkModelname() {
            var reg = /\s/g; //非空格
            var name = document.getElementById("modelName").value;
            name = name.replace(/(^\s*)|(\s*$)/g, ''); //去掉前后空格

            if (name != null && name != "") {
                if (reg.test(name)) {
                    alertMsg.error('模块名称中不得有空格！');
                    $('#modelName').val('');
                    return false;
                }
                var l = getByteLen(name);
                if (l > 20) {
                    alertMsg.error('模块名称最多为20位字符！(中文相当于2个字符)');
                    return false;
                }
            }
            return true;
        }
        function checkModelurl() {
            var reg_k = /\s/g; //非空格
            var reg_z = /[^\x00-\xff]/g; ; //有中文
            //var reg = /[\s|\u4e00-\u9fa5]/g; //非空格和中文字符
            var url = document.getElementById("txturl").value;
            url = url.replace(/(^\s*)|(\s*$)/g, ''); //去掉前后空格
            if (url != null && url != "") {
                if (reg_k.test(url)) {
                    alertMsg.error('URL地址中不得有空格。');
                    $('#txturl').val('');
                    return false;
                }
                if (reg_z.test(url)) {
                    alertMsg.error('URL地址中不得有中文字符。');
                    $('#txturl').val('');
                    return false;
                }
                if (url.length > 200) {
                    alertMsg.error('URL地址最多为200位字符！');
                    return false;
                }
            }
            return true;
        }
        //获取字符位数，中文占两位字符
        function getByteLen(val) {
            var len = 0;
            for (var i = 0; i < val.length; i++) {
                if (val[i].match(/[^\x00-\xff]/ig) != null) //全角
                    len += 2;
                else
                    len += 1;
            }
            return len;
        }
    </script>
</head>
<body>
    <div class="pageContent">
        <form id="form1" method="post" action="Handler/ModulHandler.ashx" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
        <input type="hidden" name="action" value="<%=Action %>" />
        <input type="hidden" name="id" value="<%=Id %>" />
        <div class="pageFormContent nowrap" layouth="56">
            <p>
                <label>
                    模块名称：</label>
                <input type="text" name="modelName" size="30" id="modelName"  onblur="checkModelname();" maxlength="20" class="required"
                    alt="请输入名称" value="<%=ModelName %>" />
            </p>
            <p>
                <label>
                    URL：</label>
                <input type="text" id="txturl" name="url" size="30" onblur="checkModelurl();"  maxlength="200" class="required" alt="请输入URL" value="<%=Url %>" />
            </p>
            <p>
                <label>
                    所属上级：</label>
                <select name="fatherName" id="father" style="width: 182">
                   <option value="">--请选择--</option>
                   <asp:Repeater runat="server" ID="reptModel">
                        <ItemTemplate>
                         <option value="<%#Eval("action_columnid") %>"><%#Eval("action_columnname")%></option>
                        </ItemTemplate>
                     </asp:Repeater>
                </select>
            </p>
            <p>
                <label>
                    模块排序：</label>
                <input type="text" name="actionSort" size="30" id="txtSort" maxlength="15" class="required number"
                     value="<%=ActionSort %>"/>
            </p>
        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">
                                提交</button></div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="reset" class="close">
                                取消</button></div>
                    </div>
                </li>
            </ul>
        </div>
        </form>
    </div>
</body>
</html>
